/**
 *    @file       threadrwlock.h
 *
 *    @brief      
 *    @details
 *
 *    @version    1.0
 *    @date       12/12/2012 11:43:11 AM
 *
 *    @author     Theophilus, wangtf418@gmail.com
 */
#ifndef _BF_THREADRWLOCK_H_
#define _BF_THREADRWLOCK_H_
#include <pthread.h>

class threadrwlock
{
public:
	threadrwlock()
	{
		pthread_rwlock_init(&m_rwlock, NULL);
	}

	~threadrwlock()
	{
		pthread_rwlock_destroy(&m_rwlock);
	}

public:
	inline void read_lock()
	{
		pthread_rwlock_rdlock(&m_rwlock);
	}

	inline void write_lock()
	{
		pthread_rwlock_wrlock(&m_rwlock);
	}

	inline void release_lock()
	{
		pthread_rwlock_unlock(&m_rwlock);
	}

private:
	pthread_rwlock_t m_rwlock;
};

#endif

